import {Action, commit} from '@/store/Utils';
import {deepAssign} from '@/base/util/Objects';

export class PrePathState {
  url = ''
}

abstract class BaseAction implements Action {
  namespace? = 'prePath';
}

class SetAction extends BaseAction {
  url?: string;

  static typed(state: PrePathState, payload: SetAction): void {
    deepAssign(state, payload);
  }
}

export const prePath = {
  namespaced: true,
  state: new PrePathState(),
  getters: {},
  actions: {},
  mutations: {
    [SetAction.name]: SetAction.typed
  }
};

export class prePathBloc {
  static getPrePath(url: string) {
    commit(SetAction, {url});
  };
}
